package com.example.qxfw.common.service.impl;

import com.example.qxfw.common.entity.DangerSource;
import com.example.qxfw.common.mapper.DangerSourceMapperXml;
import com.example.qxfw.common.service.DangerSourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/************************************
 *
 * @author : HuangDeYin Jolly
 * @since : JDK 11
 * @Date : 2023/7/8  星期六   15:26
 * @description : 此类用来
 ***************************************/
@Service
public class DangerSourceServiceImpl implements DangerSourceService {

    @Autowired
    private DangerSourceMapperXml dangerSourceMapperXml;





    @Override
    public Integer save(final List<DangerSource> dataList) {
        List<Integer> result = new ArrayList<>();
        dataList.forEach(dangerSource -> {
            int insertSelective = this.dangerSourceMapperXml.insertSelective(dangerSource);
            result.add(insertSelective);
        });
        if (result.contains(0)){
            return -1;
        }else {
            return 1;
        }

    }

    @Override
    public List<DangerSource> list() {
        return dangerSourceMapperXml.getAllOrById(null);
    }
}
